package org.david.test;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;

import com.tueye.base.util.IBaseHbnDao;
import com.tueye.cache.TuEyeCache;
import com.tueye.entity.TopicType;
import com.tueye.service.ITopicService;
import com.tueye.service.exception.TuEyeServiceException;
import com.tueye.utils.BaseServiceTests;
/**
 * 单元测试
 * @author hanxiaowei
 *
 */
public class PictureTest2 extends BaseServiceTests{
	private Log log = LogFactory.getLog(PictureTest2.class);
	private ITopicService topicService;
	private TuEyeCache tueyecache;
	private IBaseHbnDao  baseHbnDao;

	 @Test 
	 public void testgetAllCommentsByPId() throws TuEyeServiceException{
		 /*List<Comment> comments = topicService.getAllCommentsByPId("208DBE1F3AE7F6A26B123203120654610");
		 List commentsjson  = new ArrayList();
			for(Iterator iter = comments.iterator(); iter.hasNext();){
				Comment comment = (Comment) iter.next();
				Map map = new HashMap();
				map.put("commentcontent", comment.getCommentcontent());
				map.put("ee", comment.getCommentusername());
				map.put("pictur", comment.getPicture());
				commentsjson.add(map);
			}
			Map map2 = new HashMap();
			map2.put("dd", commentsjson);
			com.tueye.ajax.json.JSONObject object = new com.tueye.ajax.json.JSONObject(map2);
			System.out.println(object.toString());*/
		// Pictures picture = topicService.getPictureById("54E21743BD09DA466712325503932653");
		 
		// System.out.println(picture.getPicture_description());
//		log.info("测试图片信息");
//		List l =  baseHbnDao.queryList("select id,topic_title from Topics");
//		for(Iterator iter  = l.iterator() ; iter.hasNext();){
//			 Object[] o = (Object[]) iter.next();
//			 System.out.println(o[1]);
//		}
//		System.out.println(l.size());
		// baseHbnDao.queryBySqlList(sql)
		//select count(*) from comments where comments.picture.id in (select id from picture where pictur.topic id=)
//		 List l = baseHbnDao.queryList("select count(*) from Comment c where c.picture.id in (select id from Pictures p where " +
//		 		"p.topics.id = 'BA93BD67639B0E46F212380380269061')");
//		 
		//System.out.println(l.get(0));
		 
//		 String hql = "select user from UserCollectionInfo t where t.userTopicType=1 and t.topics.id = '8A239A1C5892A9264312392748638759'";
//		 List l = baseHbnDao.queryList(hql);
//		 User u = (User) l.get(0);
//		 System.out.println(u.getByname());
		  //String sql = "select adinfo_title,adinfo_level from tueye_adinfo_info";
		  //List l = baseHbnDao.queryBySqlList(sql);
		 String hql = " from TopicType t where t.pid is null";
		 List<TopicType> topicTypes = baseHbnDao.queryList(hql);
		 TopicType tts =topicTypes.get(0);
		 System.out.println(topicTypes.size());
		 System.out.println(tts.getType_name());
		  /*Object obj = l.get(0);
		  System.out.println(obj);
		  System.out.println(l.size());*/
		 
	 }

	@Override
	public void init() {
		// TODO Auto-generated method stub
		this.tueyecache = (TuEyeCache) getBean("tueyecache");
		this.baseHbnDao = (IBaseHbnDao) getBean("baseHbnDao");
		this.topicService = (ITopicService) getBean("topicService");
	}

}
